package com.wn.test;

import com.wn.entity.Role;
import com.wn.entity.User;
import com.wn.validator.RoleAddGroup;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import jakarta.validation.ValidatorFactory;
import jakarta.validation.groups.Default;
import org.junit.Test;

import java.util.Set;


public class testRole {
    @Test
    public void testRole1(){

        ValidatorFactory factory = Validation.buildDefaultValidatorFactory();

        Validator validator =  factory.getValidator();

        Role role = new Role();
        role.setName("白给");

        User user = new User();
        role.setUser(user);

        Set<ConstraintViolation<Role>> set = validator.validate(role, RoleAddGroup.class);

        set.forEach(c -> System.out.println(c.getMessage()));
    }
}